<!--
 * @Author: WeijianXu weijian.xu@unidt.com
 * @Date: 2024-05-21 11:40:58
 * @LastEditors: WeijianXu weijian.xu@unidt.com
 * @LastEditTime: 2024-05-30 14:46:39
 * @FilePath: \front-end-of-task-center\src\views\custom-forms\digit-business-report\detail.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <report-form ref="reportFormRef" disabled>
  </report-form>
</template>

<script>
import { getProcessInstance } from "@/api/bpm/processInstance";
import ReportForm from './report-form.vue';

export default {
  components: {
    ReportForm,
  },
  props: {
    processInstanceId: {
      type: String,
    },
  },
  computed: {
    instanceId() {
      return this.processInstanceId || this.$route.query.processInstanceId || '';
    },
  },
  watch: {
    instanceId: {
      handler(val) {
        if (!val) {
          this.$message.error('未传递 processInstanceId 参数，无法查看信息');
          return;
        }
        this.getDetail();
      },
    },
  },
  mounted() {
    this.getDetail();
  },
  methods: {
    /** 获得请假信息 */
    getDetail() {
      getProcessInstance(this.instanceId).then(response => {
        this.$refs.reportFormRef?.setFormData(response.data?.formVariables || {});
      });
    },
  },
}
</script>
